package ysw.action;
import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import ysw.vo.*;
import ysw.jdbc.*;
import org.apache.struts2.ServletActionContext;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
public class PayAction extends ActionSupport{
	private Pay pay;
    public Pay getPay(){
        return pay;
    }
    public void setPay(Pay pay){
        this.pay=pay;
    }
    private List<Pay> payList;
    public String execute() throws Exception{
    
        PayJdbc payJ=new PayJdbc();
        pay.setPayid(pay.getPayid());
        pay.setPaymoney(pay.getPaymoney());
        pay.setPaytime(pay.getPaytime());
        pay.setPaytype(pay.getPaytype());
        payJ.addPay(pay);
        return SUCCESS;
    }
    

public String showAllIncome(){
        @SuppressWarnings("unused")
		Pay pay=new Pay();
     PayJdbc payJ=new PayJdbc();
        try{
            payList=payJ.showPay();
        }catch(SQLException e){
            e.printStackTrace();
        }
    
		Map request=(Map)ActionContext.getContext().get("request");
        request.put("payList",payList);
        return SUCCESS;
    }
public String deletePay()throws Exception{
    Pay pay=new Pay();
    PayJdbc payJ=new PayJdbc();
    payJ.deletePay(pay.getPayid());
    System.out.println(pay.getPayid()+"pay.getPayid()");
    return SUCCESS;
    
}




public String updateSavePay() throws Exception{
    PayJdbc payJ=new PayJdbc();
   
     pay.setPayid(pay.getPayid());
        pay.setPaymoney(pay.getPaymoney());
        pay.setPaytime(pay.getPaytime());
        pay.setPaytype(pay.getPaytype());
    payJ.updateSavePay(pay);
    return SUCCESS;
}

}


